package com.hospital.dictionary.module.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.dictionary.common.DictModel;
import com.hospital.dictionary.module.controller.dto.DuplicateCheckVo;
import com.hospital.dictionary.module.entity.SysDict;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SysDictMapper extends BaseMapper<SysDict> {

    int isTableExist(String tableName);

    int createTable(String tableName);

    void changeTable(String tableName);

    void changeTableProperty(String tableName);

    void changeTableProperty2(String tableName);

    void changeTableProperty3(String tableName);
    void changeTableProperty4(String tableName);

    public Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo);
    public Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo);

    public List<DictModel> queryDictItemsByCode(@Param("code") String code);

    public String queryDictTextByKey(@Param("code") String code, @Param("key") String key);
    /**
     * 查询所有部门 作为字典信息 id -->value,departName -->text
     * @return
     */
    public List<DictModel> queryAllDepartBackDictModel();

    /**
     * 查询所有用户  作为字典信息 username -->value,realname -->text
     * @return
     */
    public List<DictModel> queryAllUserBackDictModel();

    /**
     * 删除
     * @param id
     */
    @Select("delete from sys_dict where id = #{id}")
    public void deleteOneById(@Param("id") String id);

    /**
     * 查询被逻辑删除的数据
     * @return
     */
    @Select("select * from sys_dict where del_flag = 1")
    public List<SysDict> queryDeleteList();

    /**
     * 修改状态值
     * @param delFlag
     * @param id
     */
    @Update("update sys_dict set del_flag = #{flag,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR}")
    public void updateDictDelFlag(@Param("flag") int delFlag, @Param("id") String id);
}
